package com.lyb.ui.controller;

import com.lyb.Utils;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Button;
import javafx.scene.control.TextArea;
import javafx.stage.Stage;

import java.net.URL;
import java.util.ResourceBundle;

/**
 * 文件内容输入页面的控制器
 *
 * @author Dayun Mr.Alpaca
 * @version 1.4.0
 */
public class InputController implements Initializable {
    @FXML
    public TextArea fileContentText;
    @FXML
    public Button saveButton;

    @Override
    public void initialize(URL location, ResourceBundle resources) {
        saveButton.setOnAction(event -> {
            /* 接收文件内容后唤醒系统处理 */
            synchronized (Utils.class) {
                Utils.setFileContent(fileContentText.getText() + "\n");
                Stage stage = (Stage) saveButton.getScene().getWindow();
                stage.close();
                Utils.class.notify();
            }
        });
    }
}
